package com.qeegoo.b2bautozityp.moudle.detail.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.qeegoo.b2bautozityp.R;
import com.qeegoo.b2bautozityp.moudle.detail.bean.DetailBean;

import java.util.List;

/**
 * Created by HongQian.Wang on 2017/10/18.
 */
public class RightAdapter extends BaseAdapter {
    private TextView inquery_detail_type;
    private TextView inquery_detail_name;
    private TextView inquery_detail_kind;
    private TextView inquery_detail_oe;
    private TextView inquery_detail_product_name;
    private TextView inquery_detail_quility;
    private TextView inquery_detail_price;
    private ImageView inquery_detail_pic1;
    private ImageView inquery_detail_pic2;
    private ImageView inquery_detail_pic3;
    private List<DetailBean.GoodsInfoMoreListBean.AskPriceQuoteGoodsListBean> askPriceQuoteGoodsList;


    @Override
    public int getCount() {

        return askPriceQuoteGoodsList==null?0:askPriceQuoteGoodsList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        View cell_ask_detail = LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_ask_detail, parent, false);
        initCellWidget(cell_ask_detail);
        DetailBean.GoodsInfoMoreListBean.AskPriceQuoteGoodsListBean bean = askPriceQuoteGoodsList.get(position);
        inquery_detail_type.setText(bean.getProductName());
        inquery_detail_name.setText(bean.getGoodsName());
        inquery_detail_kind.setText(bean.getGoodsStyle());
        inquery_detail_oe.setText(bean.getOem());
        inquery_detail_product_name.setText(bean.getBrandName());
        inquery_detail_quility.setText(bean.getGoodsType()+"");
        inquery_detail_price.setText(bean.getPrice()+"");

        Glide.with(parent.getContext()).load(bean.getImgUrl1()).centerCrop().into(inquery_detail_pic1);
        Glide.with(parent.getContext()).load(bean.getImgUrl2()).centerCrop().into(inquery_detail_pic2);
        Glide.with(parent.getContext()).load(bean.getImgUrl3()).centerCrop().into(inquery_detail_pic3);

        return cell_ask_detail;
    }

    private void initCellWidget(View cell_ask_detail) {
        inquery_detail_type = (TextView) cell_ask_detail.findViewById(R.id.inquery_detail_type);
        inquery_detail_name = (TextView) cell_ask_detail.findViewById(R.id.inquery_detail_name);
        inquery_detail_kind = (TextView) cell_ask_detail.findViewById(R.id.inquery_detail_kind);
        inquery_detail_oe = (TextView) cell_ask_detail.findViewById(R.id.inquery_detail_oe);
        inquery_detail_product_name = (TextView) cell_ask_detail.findViewById(R.id.inquery_detail_product_name);
        inquery_detail_quility = (TextView) cell_ask_detail.findViewById(R.id.inquery_detail_quility);
        inquery_detail_price = (TextView) cell_ask_detail.findViewById(R.id.inquery_detail_price);
        inquery_detail_pic1 = (ImageView) cell_ask_detail.findViewById(R.id.inquery_detail_pic1);
        inquery_detail_pic2 = (ImageView) cell_ask_detail.findViewById(R.id.inquery_detail_pic2);
        inquery_detail_pic3 = (ImageView) cell_ask_detail.findViewById(R.id.inquery_detail_pic3);
    }
    public void setDataAndRefreshed(List<DetailBean.GoodsInfoMoreListBean.AskPriceQuoteGoodsListBean> askPriceQuoteGoodsList){
         this.askPriceQuoteGoodsList=askPriceQuoteGoodsList;
         notifyDataSetChanged();
    }
}
